/**
 * Created by chl on 2016/10/13.
 */
function popup(width, height, page) {
    parent.layer.open({
        type: 2,
        title: false,
        closeBtn:0,
        skin: 'clothing',
        scrollbar:false,
        shadeClose: false, //点击关闭遮罩层
        area: [width, height],
        content: page,
        //scrollbar: false,
        shade:0.4,
        shift:false,
        loading:1,
        success: function(layero){

            //layero.keydown(function (e) {
            //    if($(':focus').length==0){
            //        if (e.keyCode == 8) {
            //            return false;
            //        }
            //    }else
            //});
        },
    });

}


function tip(page){
    layer.msg(page,{
        time: 2000 //2秒关闭（如果不配置，默认是3秒）
    })
}

function closeWin() {
    var index = parent.layer.getFrameIndex(window.name);
    parent.layer.close(index);
}

function tipParent(page){
    parent.layer.msg(page,{
        time: 2000 //2秒关闭（如果不配置，默认是3秒）
    })
}

function alertInfo(infoTxt){
    parent.layer.alert(infoTxt)
}

function del(){
    parent.layer.open({
        title:false,
        content:'<img src="static/images/icon_info.png" class="incoInfo">您确定要删除这条记录吗？',
        area: ['300px', '150px'],
        closeBtn:0,
        btn: ['确认', '取消']
    });
}

function del(callback){
    parent.layer.confirm('<img src="static/images/icon_info.png" class="incoInfo">您确定要删除这条记录吗？', {
            title:false,
            closeBtn:0,
            btn: ['确认', '取消'], //按钮
            area: ['300px', '150px']
        }, function(){
        callback();

        }, function(){
        }
    );
}


window.onload = function(){
    //文本溢出
    $(".rtname").each(function(){
        var divH = $(this).height();
        if(divH > 40) {
            $(this).addClass('textOver')
        };
    });


}
//删除键禁止退回浏览记录
$(window).keydown(function(e){
    if($('input,select,textarea').is(":focus")){
    }else{
        if (e.keyCode == 8) {
            return false;
        }
    }
})
//图片缩略图 
$(".tableImg").hover(function(){
        var thisImg = $(this).next('.posImg');
        var thisW = $(this).width();
        var thisH = $(this).height();
        thisImg.css({
        	width:thisW*2 + "px",
            height:thisH*2 + "px"
        });
        var thisImgW = thisImg.width();
        var thisImgH = thisImg.height();
        var thisImgTop = $(this).offset().top;
        var thisImgLeft = $(this).offset().left;
        thisImg.css({
            top:thisImgTop - (thisImgH - thisH)/2 + "px",
            left:thisImgLeft - (thisImgW - thisW)/2 + "px",
        })
        
        thisImg.show()
    });

    $(".posImg").hover(function(){
//        移入
    },function(){
        $(this).hide()
    });


  //多项图片缩略图 
	function thumbnail() {
		$.each($(".tableImg"),function(i,e){
			$(e).hover(function(){
		        var thisImg = $(this).next('.posImg');
		        var thisW = $(this).width();
		        var thisH = $(this).height();
		        thisImg.css({
		            width:thisW*2 + "px",
		            height:thisH*2 + "px"
		        });
		        var thisImgW = thisImg.width();
		        var thisImgH = thisImg.height();
		        var thisImgTop = $(this).offset().top;
		        var thisImgLeft = $(this).offset().left;
		        thisImg.css({
		            top:thisImgTop - (thisImgH - thisH)/2 + "px",
		            left:thisImgLeft - (thisImgW - thisW)/2 + "px",
		        });
		        
		        thisImg.show();
		    });
		})
		$.each($(".posImg"),function(i,e){
		    $(e).hover(function(){
		//        移入
		    },function(){
		        $(this).hide();
		    });
		})
	}
